var t = e(require("@vant/weapp/dialog/dialog")), a = e(require("@vant/weapp/toast/toast"));

function e(t) {
    return t && t.__esModule ? t : {
        default: t
    };
}

var o = require("../../utils/config"), c = require("../../utils/api"), n = require("../../utils/request"), r = require("../../utils/storage");

Component({
    properties: {
        checkCards: Array,
        type: String
    },
    data: {
        themeColor: getApp().globalData.themeColor,
        loading: !1,
        popupId: "",
        popupshow: !1,
        x: 0,
        y: 0
    },
    lifetimes: {
        attached: function() {},
        detached: function() {},
        ready: function() {}
    },
    methods: {
        goResv: function(t) {
            var e = r.getStorageSync(r.storageKey.uid), d = this;
            console.log("消息模板集合：", o.subscribeMessageTmplIds), wx.requestSubscribeMessage({
                tmplIds: o.subscribeMessageTmplIds,
                success: function(s) {
                    console.log("订阅消息成功", s), d.setData({
                        loading: !0
                    }), n.request(n.HttpMethod.GET, c.apiRoute.getKhdwdzfsByldid + t.target.dataset.card.ldno, {}).then(function(s) {
                        if ("2" == s.data) return (0, a.default)({
                            message: "此卡或此套餐是从第三方线上平台购买，请使用购买方平台进行预约",
                            duration: 3e3
                        }), void d.setData({
                            loading: !1
                        });
                        o.getH5ResvUrl().then(function(a) {
                            var o = t.target.dataset.card.checkCardNo, s = !([ "CRS_BulkLd", "ZJ_OutSideInPut", "WEB_BulkResv", "PQ_Bulkld", "PQ_BulkLd", "KA_Family", "KA_WEB_BULK_RESV" ].indexOf(t.target.dataset.card.sourceValue) >= 0), i = t.target.dataset.card.resvPid || "", u = t.target.dataset.card.vip || "0", l = t.target.dataset.card.companyCode, g = t.target.dataset.card.ldno, p = e || "", v = a, h = "cardNo=".concat(o, "&bindCard=").concat(s, "&isVIP=").concat(u, "&resvPid=").concat(i, "&companyID=").concat(l, "&ldNo=").concat(g, "&isVCard=").concat(!0, "&source=wechatAppletNew&operator=").concat(p), f = r.getStorageSync(r.storageKey.locationInfo);
                            null != f && null != f && "" != f && (h += "&pointY=".concat(f.latitude, "&pointX=").concat(f.longitude)), 
                            console.log("para", h), n.request(n.HttpMethod.POST, c.apiRoute.encodeResvUrl, {
                                urlpara: h
                            }).then(function(t) {
                                var a = "".concat(v, "&accesskey=").concat(t.url);
                                wx.navigateTo({
                                    url: "/pages/webview/webview?h5=".concat(encodeURIComponent(a)),
                                    success: function() {
                                        d.setData({
                                            loading: !1
                                        });
                                    }
                                });
                            });
                        });
                    });
                },
                fail: function(s) {
                    console.log("订阅消息失败", s), d.setData({
                        loading: !0
                    }), n.request(n.HttpMethod.GET, c.apiRoute.getKhdwdzfsByldid + t.target.dataset.card.ldno, {}).then(function(s) {
                        if ("2" == s.data) return (0, a.default)({
                            message: "此卡或此套餐是从第三方线上平台购买，请使用购买方平台进行预约",
                            duration: 3e3
                        }), void d.setData({
                            loading: !1
                        });
                        o.getH5ResvUrl().then(function(a) {
                            var o = t.target.dataset.card.checkCardNo, s = !([ "CRS_BulkLd", "ZJ_OutSideInPut", "WEB_BulkResv", "PQ_Bulkld", "PQ_BulkLd", "KA_Family", "KA_WEB_BULK_RESV" ].indexOf(t.target.dataset.card.sourceValue) >= 0), i = t.target.dataset.card.resvPid || "", u = t.target.dataset.card.vip || "0", l = t.target.dataset.card.companyCode, g = t.target.dataset.card.ldno, p = e || "", v = a, h = "cardNo=".concat(o, "&bindCard=").concat(s, "&isVIP=").concat(u, "&resvPid=").concat(i, "&companyID=").concat(l, "&ldNo=").concat(g, "&isVCard=").concat(!0, "&source=wechatAppletNew&operator=").concat(p), f = r.getStorageSync(r.storageKey.locationInfo);
                            null != f && null != f && "" != f && (h += "&pointY=".concat(f.latitude, "&pointX=").concat(f.longitude)), 
                            console.log("para", h), n.request(n.HttpMethod.POST, c.apiRoute.encodeResvUrl, {
                                urlpara: h
                            }).then(function(t) {
                                var a = "".concat(v, "&accesskey=").concat(t.url);
                                wx.navigateTo({
                                    url: "/pages/webview/webview?h5=".concat(encodeURIComponent(a)),
                                    success: function() {
                                        d.setData({
                                            loading: !1
                                        });
                                    }
                                });
                            });
                        });
                    });
                }
            });
        },
        goCheck: function(t) {
            var a = this;
            a.setData({
                loading: !0
            }), o.getH5ResvDetailUrl().then(function(e) {
                var o = r.getStorageSync(r.storageKey.uid), d = t.target.dataset.card.checkCardNo, s = !([ "CRS_BulkLd", "ZJ_OutSideInPut", "WEB_BulkResv", "PQ_Bulkld", "PQ_BulkLd", "KA_Family", "KA_WEB_BULK_RESV" ].indexOf(t.target.dataset.card.sourceValue) >= 0), i = t.target.dataset.card.resvPid || "", u = t.target.dataset.card.vip || "0", l = t.target.dataset.card.companyCode, g = t.target.dataset.card.ldno, p = t.target.dataset.card.isVcard || !0, v = o || "", h = "cardNo=".concat(d, "&bindCard=").concat(s, "&isVIP=").concat(u, "&resvPid=").concat(i, "&companyID=").concat(l, "&ldNo=").concat(g, "&showButton=true&isVCard=").concat(p, "&source=wechatAppletNew&operator=").concat(v), f = e, w = r.getStorageSync(r.storageKey.locationInfo);
                null != w && null != w && "" != w && (h += "&pointY=".concat(w.latitude, "&pointX=").concat(w.longitude)), 
                n.request(n.HttpMethod.POST, c.apiRoute.encodeResvUrl, {
                    urlpara: h
                }).then(function(t) {
                    var e = "".concat(f, "&accesskey=").concat(t.url);
                    wx.navigateTo({
                        url: "/pages/webview/webview?h5=".concat(encodeURIComponent(e)),
                        success: function() {
                            a.setData({
                                loading: !1
                            });
                        }
                    });
                });
            });
        },
        viewDetail: function(t) {
            var a = this;
            console.log("will show detail"), a.setData({
                loading: !0
            }), o.getH5ResvDetailUrl().then(function(e) {
                var o = r.getStorageSync(r.storageKey.uid), d = t.target.dataset.card.checkCardNo, s = !([ "CRS_BulkLd", "ZJ_OutSideInPut", "WEB_BulkResv", "PQ_Bulkld", "PQ_BulkLd", "KA_Family", "KA_WEB_BULK_RESV" ].indexOf(t.target.dataset.card.sourceValue) >= 0), i = t.target.dataset.card.resvPid || "", u = t.target.dataset.card.vip || "0", l = t.target.dataset.card.companyCode, g = t.target.dataset.card.ldno, p = t.target.dataset.card.isVcard || !0, v = o || "", h = "cardNo=".concat(d, "&bindCard=").concat(s, "&isVIP=").concat(u, "&resvPid=").concat(i, "&companyID=").concat(l, "&ldNo=").concat(g, "&showButton=true&isVCard=").concat(p, "&source=wechatAppletNew&operator=").concat(v);
                console.log("para", h);
                var f = r.getStorageSync(r.storageKey.locationInfo);
                null != f && null != f && "" != f && (h += "&pointY=".concat(f.latitude, "&pointX=").concat(f.longitude));
                var w = e;
                n.request(n.HttpMethod.POST, c.apiRoute.encodeResvUrl, {
                    urlpara: h
                }).then(function(t) {
                    console.log("加密后的url：", t.url);
                    var e = "".concat(w, "&accesskey=").concat(t.url);
                    wx.navigateTo({
                        url: "/pages/webview/webview?h5=".concat(encodeURIComponent(e)),
                        success: function() {
                            a.setData({
                                loading: !1
                            });
                        }
                    });
                });
            });
        },
        unBind: function(a) {
            var e = this, o = this;
            o.setData({
                loading: !0
            });
            var r = a.target.dataset.card.checkCardNo, d = [];
            d.push(r), t.default.confirm({
                message: "确定解绑吗？"
            }).then(function() {
                n.request(n.HttpMethod.POST, c.apiRoute.unBindCheckCardByCardNo, {
                    checkCardNoList: d
                }).then(function(t) {
                    "20000" == t.code && (o.setData({
                        loading: !1
                    }), e.setData({
                        x: 0,
                        y: 0,
                        popupshow: !1,
                        popupId: ""
                    }), e.triggerEvent("onReload"));
                });
            }).catch(function() {
                o.setData({
                    loading: !1
                }), console.log("未解绑");
            });
        },
        showPopupAction: function(t) {
            var a = t.detail, e = a.x, o = a.y;
            this.setData({
                x: e,
                y: o,
                popupshow: !this.data.popupshow,
                popupId: t.target.dataset.card.id
            });
        }
    }
});